//引入 koa模块
const Koa = require('koa');
const router = require('koa-router')();
const bodyParser = require('koa-bodyparser');
const koaBody = require('koa-body');
//实例化
const app = new Koa();
//配置post提交数据的中间件
app.use(koaBody({
  multipart: true,
  formidable: {
    maxFileSize: 200 * 1024 * 1024 // 设置上传文件大小最大限制，默认2M
  }
}));
app.use(bodyParser());
//引入模块
const api = require('./server/admin.js');
router.use('/api', api);

// const tools = require('./server/tools.js');
// let data = '123456';
// let key = 'Password!';
// let encrypted = tools.aesEncrypt(data, key);
// let decrypted = tools.aesDecrypt(encrypted, key);
// console.log('原来的数据: ' + data);
// console.log('加密后的数据: ' + encrypted);
// console.log('还原后的数据: ' + decrypted);

app.use(router.routes()); /*启动路由*/
app.use(router.allowedMethods());
app.listen(3000);
